/* This script expects the following client parameters: * applicationPath = the full local file path to the directory containing the source files. Output will go here, too. * projectName = Name of project being compiled. If project is foo, web file will be foo.web * verbose = "true" for verbose output, "false" otherwise Also, it assumes there is a filelist file, called "filelist" in the "path" directory containing names of all files to compile, and that jsac.exe is on the current PATH. Notes: The directory containing the java class Calljsac must be in the system's CLASSPATH. For example, if the compiler app is in D:\Netscape\SuiteSpot\js\samples\compiler, the call below assumes that the CLASSPATH points to D:\Netscape\SuiteSpot\js\samples. */ // Used as a constant, COMPILER_EXEC represents the name of the executable for // the jsac compiler. var COMPILER_EXEC = "jsac"; // Initialize file list variable. This assumes an include file with the name "filelist" var filelist = "filelist"; //////////////////////////////// // Validate Form Data // //////////////////////////////// var webfilename = ""; var apppath = ""; var verboseflag = true; // Take values from client object if this page was called from the sample application. // Otherwise, assume some other application called this page directly and take values // from the request object. if (client.source == "application") { webfilename = (client.projectName != null) ? (client.projectName + ".web") : ""; apppath = (client.applicationPath != null) ? (client.applicationPath) : ""; verboseflag = (client.verbose == "ON") ? true : false; } else { webfilename = (request.projectName != null) ? (request.projectName + ".web") : ""; apppath = (request.applicationPath != null) ? (request.applicationPath) : ""; verboseflag = (request.verbose == "ON") ? true : false; } /////////////////////////////////// // Call Compiler from Java // /////////////////////////////////// // *** Call the JavaScript Compiler from Java *** var str = Packages.compiler.Calljsac.exec( COMPILER_EXEC, apppath, filelist, webfilename, verboseflag ); // Convert Java string object to JavaScript string object var jsStr = str + ""; // Determine if there were any errors reported by the compiler resultCode = jsStr.charAt(0); jsStr = jsStr.substring(2, jsStr.length); if (resultCode == "0") statusStr = "success"; else statusStr = "error"; /////////////////////////////////// // Display Compiler Output // /////////////////////////////////// GenerateTitleBar ( statusStr, "pics" ); // Write out pre-compiler errors or compiler output GenerateResults(statusStr, jsStr, verboseflag, webfilename); // If instructed to restart as well, then do so if ( ((client.source == "application") && (client.restartFlag == "true")) || ((request.source == "application") && (request.restartFlag == "true")) ) { write(''); }